// index.js
class MessageBroker {
    constructor() {
        if (this.constructor === MessageBroker) {
            throw new Error('Abstract class cannot be instantiated');
        }
    }

    async publish(taskType, message) {
        throw new Error('Method not implemented');
    }

    async subscribe(taskType, callback) {
        throw new Error('Method not implemented');
    }

    async start() {
        throw new Error('Method not implemented');
    }

    async close() {
        throw new Error('Method not implemented');
    }

    truncateMessage(message, maxLength = 50) {
        const imagePath = message.inputs.image_path || null;
        if (imagePath && typeof imagePath === 'string' && imagePath.startsWith('data:image/')) {
            const truncateMessage = { ...message };
            const truncateInput = { ...message.inputs };
            truncateInput.image_path = imagePath.substring(0, maxLength) + '...';
            truncateMessage.inputs = truncateInput;
            return truncateMessage;
        } else {
            return message;
        }
    }
}

module.exports = { MessageBroker };
